
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
	<title>正则敏感词标红</title>
	<style>
		#test {width: 500px;height: 300px;border: 2px dashed purple;}
	</style>
	
</head>
<body>
	<textarea name="" id="test" cols="30" rows="10"></textarea>
	<script>
		window.onload = function() {
			var test = document.querySelector('#test');
			var re = /测试|低端人口|我去/g;
			test.oninput = function() {
				var val = this.value;
				var arr = val.match(re)||[];
				if(arr.length>0) {
					for(var i=0;i<arr.length;i++) {
						// arr[i].style.color='red';
					}
				}
			}
		}
	</script>
</body>
</html>